package engineer;

import entity_model.Attribute;
import entity_model.Entity;
import entity_model.EntityModel;
import entity_model.Relationship;
import entity_model.data_types.DataType;
import entity_model.json.deserializers.*;
import entity_model.json.serializers.EntitySerializer;
import entity_model.json.serializers.RoleSerializer;
import utils.Folder;
import utils.Utils;
import utils.titles.Title;
import utils.titles.TitleDeserializer;
import utils.titles.TitleSerializer;

/**
 * Created by nuno-rafael-figueiredo on 11-07-2014.
 */
public class Engineer {
    private Engineer() {
    }

    public static final Folder FOLDER = Folder.USER_HOME.createFolder("Engineer");


    static {
        Utils.GSON_BUILDER
                .registerTypeAdapter(EntityModel.class, new EntityModelDeserializer())
                .registerTypeAdapter(Entity.class, new EntityDeserializer())
                .registerTypeAdapter(Entity.class, new EntitySerializer())
                .registerTypeAdapter(Attribute.class, new AttributeDeserializer())
                .registerTypeAdapter(Relationship.class, new RelationshipDeserializer())
                .registerTypeAdapter(Relationship.Role.class, new RoleSerializer())
                .registerTypeAdapter(Relationship.Role.class, new RoleDeserializer())
                .registerTypeAdapter(Title.class, new TitleSerializer())
                .registerTypeAdapter(Title.class, new TitleDeserializer())
                .registerTypeAdapter(DataType.class, new DataType.TypeAdapter());
    }

    public static String toJson(Object o) {
        return Utils.getGson().toJson(o);
    }
}
